{include file="public/header" /}
<form class="layui-form">
	<div class="layui-form-item">
		<label class="layui-form-label">导航名</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="label" placeholder="请输入导航名">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图标</label>
		<div class="layui-input-block">
			<select name="icon_class" lay-verify="required" lay-search="">
				<option value="">请输入layui图标</option>
				{foreach($iconfont as $icon_v)}
					<option value="{$icon_v['icon_css']}">{$icon_v['icon_css']} {$icon_v['icon_name']}</option>
				{/foreach}
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">类型</label>
		<div class="layui-input-inline">
			<select name="type" lay-filter="type">
				<option value='0' selected>分组</option>
				<option value='1'>内部代码</option>
				<option value='2'>超链接</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item" style="display:none;" id="src1">
		<label class="layui-form-label">内部代码</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="src1" placeholder="请输入：模块/方法">
		</div>
	</div>
	<div class="layui-form-item" style="display:none;" id="src2">
		<label class="layui-form-label">链接地址</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="src2" placeholder="请输入http网址">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">排序</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="sort" placeholder="值越大越靠前">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">备注</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="remark" placeholder="请输入备注"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">状态</label>
		<div class="layui-input-block">
			<input type="radio" name="status" value="1" title="开启" checked>
			<input type="radio" name="status" value="0" title="禁用">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">左侧菜单</label>
		<div class="layui-input-block">
			<input type="radio" name="is_show" value="1" title="显示" checked>
			<input type="radio" name="is_show" value="0" title="不显示">
		</div>
	</div>
</form>
<div class="layui-form-item" style="margin-top:10px;">
	<div class="layui-input-block">
		<button type="button" class="layui-btn" onclick="save()">保存</button>
	</div>
</div>
<script type="text/javascript">
	layui.use(['layer','form'],function(){
		var form = layui.form;
		layer = layui.layer;
		$ = layui.jquery;

		form.on('select(type)', function(data){
			if(data.value == 1){
				$("#src1").show();
				$("#src2").hide();
				$("#src3").hide();
			}else if(data.value == 2){
				$("#src1").hide();
				$("#src2").show();
				$("#src3").hide();
			}else{
				$("#src1").hide();
				$("#src2").hide();
				$("#src3").hide();
			}
		});
	});

	function save(){
		$.post('{$config["admin_route"]}bew/menuadd',$('form').serialize(),function(res){
			if(res.code>0){
				layer.msg(res.msg,{'icon':2});
			}else{
				layer.msg(res.msg,{'icon':1});
				setTimeout(function(){parent.window.location.reload();},1000);
			}
		},'json');
	}
</script>
{include file="public/tail" /}